package com.liws.helloeasyexcel.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.liws.helloeasyexcel.model.Student;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: liweisheng
 * @Dcscription:
 * @Date: 2021/12/9 13:14
 */
@Slf4j
public class StudentEventListener extends AnalysisEventListener<Student> {
    List<Student> list =  new ArrayList<>();
    @Override
    public void invoke(Student data, AnalysisContext analysisContext) {

        list.add(data);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        list.forEach(s->{
            String name = s.getName();
            log.info("name--"+name);
        });
        log.info("读取完成");
    }
}
